﻿using Ef_core.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Ef_core.Controllers
{
    [Route("api")]
    [ApiController]
    public class StudentController : ControllerBase
    {
        private readonly StudentDbcontext Dbcontext;

        public StudentController(StudentDbcontext studentDbcontext)
        {
            this.Dbcontext = studentDbcontext;
        }
        [HttpGet]
        public void AddStudet([FromQuery]string name)
        {
            Student student = new Student();
            student.Id = new Guid();
            student.Name = name;
            Dbcontext.Students.Add(student);
            Dbcontext.SaveChanges();
        }
        [HttpGet("get")]
        public Guid GetStudet()
        {
        var m=    Dbcontext.Students
                 .Where(x => x.Name == "赵")
                 .FirstOrDefault().Id;
            return m;
        }
    }
}
